<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
	
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="renderer" content="webkit">
<meta http-equiv="Cache-Control" content="no-siteapp" />
<title>竞技之星</title>
<link href="${path }/resource/css/scale-css.css" type="text/css" rel="stylesheet" />
<!--[if lt IE 8]>
    <meta http-equiv="refresh" content="0;ie.html" />
    <![endif]-->

<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
<script type="text/javascript" src="${path }/resource/js/scale.js"></script>
<script src="http://res.wx.qq.com/connect/zh_CN/htmledition/js/wxLogin.js"></script>
</head>

<body class="body-bg">
<div class="div-container">
<input type="hidden" value="${user.id}" id="userId">
<input type="hidden" value="${user.weixinId}" id="token">
<input type="hidden" value="${result }" id="result"/>
<input type="hidden" value="${isbind }" id="isbind"/>
<input type="hidden" value="${islogin }" id="islogin"/>
		<div class="title-bg">
			<div class="div-title">竞技之星</div><br>
			<div class="sub-title" style="margin-top: -290px;margin-left: 260px;">跑得快</div>
		</div>
		<div class="div-title2">${user.name }推荐您下载</div>
		<div class="div-image">		
		<div  id="shareImg"></div>
		</div>
		<div class="div-tip" style="margin-left: 150px;margin-right: 50px;">
			<p align="left">1.长按二维码，选择 "保存图片"到相册；</P>
			<p align="left">2.打开微信扫一扫，选择"从相册选取二维码"，授权并登录进入下载。</p>
		</div>
	</div>
	<div id="wxDiv" class="wx-tip" ><img id="wxImg" src="${path }/resource/images/weixin-tip.png"></img></div>
	
	<!-- <div class="-mob-share-ui-button -mob-share-open">分享</div> -->
</body>
<script type="text/javascript">
	var userId = $("#userId").val();
	var token = $("#token").val();
	var obj = new WxLogin({

    id:"shareImg", 

    appid: "wx30e22003a61a1e29", 

    scope: "snsapi_login", 

    //redirect_uri: "http://pay.jjstar.cc/client/downloadApk",
   redirect_uri: 'http://www.jjstar.cc/client/toDownload?userId='+userId,
    //redirect_uri: "http://10.0.0.124:8080/SSMTemplate/client/toDownload?userId="+userId,

    state: "3d6be0a4035d839573b04816624a416e",

    style: "white",

    href: ""

  });
	
	//下载apk
		var result = $("#result").val();
		var isbind = $("#isbind").val();
		var islogin = $("#islogin").val();
		if("yes"==islogin){
			alert("您已登录游戏,无法绑定！赶快邀请好友一起来玩吧！");
			window.location.href = "http://www.jjstar.cc/client/download-app";
			islogin="";
		}
		else if("yes"==isbind){//该帐号已绑定
			window.location.href = "http://www.jjstar.cc/client/download-app?type=1";
			isbind="";
		}else{
			if("ok"==result){
				 window.onload = function() {
		                var u = navigator.userAgent;
		                if (u.indexOf('Android') > -1 || u.indexOf('Linux') > -1) { //安卓手机
		                    //                    alert("安卓手机");
		                    //window.location.href = "http://www.yadacloud.com/app/cloud.apk";
		                    //window.location.href = "http://pay.jjstar.cc/client/downloadApk";
		                	window.location.href = "http://www.jjstar.cc/client/downloadApk";
		                } else if (u.indexOf('iPhone') > -1) { //苹果手机
		                    //                    alert("苹果手机");
		                //return "itms-services:///?action=download-manifest&url=https://git.oschina.net/juncychen/EPAP/raw/master/paodekuai.plist";
		                    window.location.href = "http://fir.im/c5en";
		                } else if (u.indexOf('Windows Phone') > -1) { //winphone手机
		                    alert("WindowsPhone暂未推出。");
		                } else if (u.indexOf('Windows NT') > -1) { //Windows电脑
		                    alert("请用手机浏览器访问。");
		                }
		            }
				 result="";
			} 
		}
		$(window).on("load", function() {
		    var winHeight = $(window).height();
		    var width = $(window).width();
		    function is_weixin() {
		        var ua = navigator.userAgent.toLowerCase();
		        if (ua.match(/MicroMessenger/i) == "micromessenger") {
		            return true;
		        } else {
		            return false;
		        }
		    }
		    var isWeixin = is_weixin();
		    if (isWeixin) {
		    	 $("#wxImg").css("height", winHeight);
		    	 $("#wxImg").css("width", width);
		         $("#wxDiv").show();
		    }
		});
</script>
</html>